package com.lg.concurrent.aqs_cas.mashibing.s2;

public class Demo2 {
    public static int sum = 0;

    public static void main(String[] args) throws InterruptedException {
        System.out.println("当前核数： " + Runtime.getRuntime().availableProcessors());
        Thread[] threads = new Thread[100];
        for (int i = 0; i < threads.length; i++) {
            threads[i] = new Thread(() -> {
                synchronized (Demo2.class){
                for (int j = 0; j < 100; j++)
                        sum++;
                }
            });
        }

        for (Thread thread : threads) {
            thread.start();
        }

        for (Thread thread : threads) {
            thread.join();
        }

        System.out.println(sum);

    }
}
